﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="find_Bill_By_Month.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Accountant.find_Bill_By_Month" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <thead>
        <tr class="w3-teal">
            <th>Mã HV</th>
            <th>Họ tên</th>
            <th>Lớp</th>
            <th>Học phí</th>
            <th>Gói</th>
            <th>Ngày đóng</th>
            <th>Ngày hết hạn</th>
        </tr>
    </thead>
    <%
        if (this.class_id == 0)
        {
            for (int i = 0; i <= 31; i += 7)
            {
    %>
    <tr>
        <td colspan="7" class="w3-center w3-text-teal">- Tuần <%=i / 7 + 1%> -</td>
    </tr>
    <%
                var get_user = from p in new TblStudyFeeController().FetchAll() where p.Active == true && DateTime.Parse(p.PayDate.ToString()).Day > i && DateTime.Parse(p.PayDate.ToString()).Day <= i + 7 && DateTime.Parse(p.PayDate.ToString()).Month == this.month && DateTime.Parse(p.PayDate.ToString()).Year == this.year orderby p.Id descending select p;
                foreach (TblStudyFee fee in get_user)
                {
                    var get_member = new TblUserController().FetchAll().Where(x => x.UserId == fee.UserId).Single();
                    var get_class = new TblClassController().FetchAll().Where(x => x.Id == get_member.ClassX).Single();
    %>
    <tr class="bill" id="bill<%=fee.Id%>" style="cursor: pointer">
        <td class="bill_id w3-hide"><%=fee.Id%></td>
        <td><%=get_member.NumberStudy%></td>
        <td><%=get_member.FullName%></td>
        <td><%=get_class.ClassName%></td>
        <td><%=fee.Fee%></td>
        <td><%=fee.Packet%> tháng</td>
        <td><%=DateTime.Parse(fee.PayDate.ToString()).Day%>/<%=DateTime.Parse(fee.PayDate.ToString()).Month%>/<%=DateTime.Parse(fee.PayDate.ToString()).Year%></td>
        <td><%=DateTime.Parse(fee.ExpDate.ToString()).Day%>/<%=DateTime.Parse(fee.ExpDate.ToString()).Month%>/<%=DateTime.Parse(fee.ExpDate.ToString()).Year%></td>
    </tr>
    <%}
            } %>
    <%
                
        }
        else
        {
            for (int i = 0; i <= 31; i += 7)
            {
    %>
    <tr>
        <td colspan="7" class="w3-center w3-text-teal">- Tuần <%=i / 7 + 1%> -</td>
    </tr>
    <%
                foreach (TblUser user in new TblUserController().FetchAll().Where(x => x.ClassX == this.class_id))
                {
                    var get_user = from p in new TblStudyFeeController().FetchAll() where p.Active == true && DateTime.Parse(p.PayDate.ToString()).Day > i && DateTime.Parse(p.PayDate.ToString()).Day <= i + 7 && DateTime.Parse(p.PayDate.ToString()).Month == this.month && DateTime.Parse(p.PayDate.ToString()).Year == this.year && p.UserId == user.UserId orderby p.Id descending select p;
                    foreach (TblStudyFee fee in get_user)
                    {
                        var get_member = new TblUserController().FetchAll().Where(x => x.UserId == fee.UserId).Single();
                        var get_class = new TblClassController().FetchAll().Where(x => x.Id == get_member.ClassX).Single();
    %>
    <tr class="bill" id="bill<%=fee.Id %>" style="cursor: pointer">
        <td class="bill_id w3-hide"><%=fee.Id%></td>
        <td><%=get_member.NumberStudy%></td>
        <td><%=get_member.FullName%></td>
        <td><%=get_class.ClassName%></td>
        <td><%=fee.Fee%></td>
        <td><%=fee.Packet%> tháng</td>
        <td><%=DateTime.Parse(fee.PayDate.ToString()).Day%>/<%=DateTime.Parse(fee.PayDate.ToString()).Month%>/<%=DateTime.Parse(fee.PayDate.ToString()).Year%></td>
        <td><%=DateTime.Parse(fee.ExpDate.ToString()).Day%>/<%=DateTime.Parse(fee.ExpDate.ToString()).Month%>/<%=DateTime.Parse(fee.ExpDate.ToString()).Year%></td>
    </tr>
    <%}
                }
            }
        }
    %>
</body>
</html>
